<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/mb/jsp/common.jsp" %>

<%@ page import="com.limao.servlet.WebFunction" %>
<%@ page import="com.limao.DBDataClass.CrowdVRHomeClass" %>
<%@ page import="com.limao.DBDataClass.CrowdVrSysGoodsClass" %>
<%@ page import="com.limao.CacheManager.CrowdVrGoodsCache" %>
<%@ page language="java" import="com.limao.DBDataClass.CrowdUserAuthClass"%>

<%
	String userid =CacheClass.isLogin_token(request,response);
    userid = (String) CacheClass.isLogin(request,response);
    if (CacheClass.getIntValue(userid) == 0) {
        out.println("<script language='JavaScript'>alert('您还没有登陆！');location.href=document.referrer;</script>"); //后退并刷新
        return;
    }
    
 CrowdUserAuthClass user= WebFunction.getUserInfo(request,response);
 if(user==null)
 {
	 out.println("<script language='JavaScript'>alert('用户不存在，或被平台禁用，请联系客服！');window.history.back(-1);</script>");
	 return;
 } 
 
 String pwdMd5= WebFunction.getUserPwd(request,response);
 
    CrowdVRHomeClass vrhome = WebFunction.getVrHomeInfo(request, response);

    List<CrowdVrSysGoodsClass> tmplist = CrowdVrGoodsCache.getInstance().Load_CrowdVRGoods();
    
    Date d=new Date();
      //当天的前一天时间
    String enddayVal=CacheClass.getDateBeforeDay4(d, 1);
    //当天的前30天时间
    String startdayVal=CacheClass.getDateBeforeDay4(d, 30);
   
%>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>市场</title>
    <link rel="stylesheet" href="mb/css/common.css" />
    <script src="mb/js/echarts.min.js"></script>
    <script type="text/javascript" src="mb/js/charts.js"></script>
</head>
<body ontouchstart="">
<div class="theme-popover-mask"></div>
<!-- <div class="detailTop pf w100 of">
    <div class="w100 of tc c3 f18">
        <span class="pa" style="left: 5px;" onclick="javascript:history.back();"><img src="mb/images/top_back.png" style="margin-top: 4px;height: 40px;width: 40px;"/></span>
        提单交易
        <div class="dib of pa" style="right: 10px;">
            <a href="mb/jsp/saveMoney.jsp" class="dib tc">资金转入</a>
        </div>
    </div>
</div> -->

<div class="container jz">
    <section class="proSection w100 bcfb">
        <form class="detailInfo w100 of pr">
            <label for="proKind" class="f14 c3 mgl10" style='margin-left:1%;'>资产品种</label>
            <select name="proKind" id="proKind" style='width:50%;'>

               
            </select> 
            <div class="dib of pa" style="right: 14px;top:0;">
            	<a href="mb/jsp/saveMoney.jsp" class="dib tc zhunRuZijinBtn">资金转入</a>
        	</div>
        </form>       
    </section>
    
    


    <section id="introDetail" class="w100 of">
        <div class="w100 of bcfb">
            <ul id="qz-Tab" class="picTab w100">
                <li data="1" class="pictab_current">分时</li>
                <li data="5" class="">5分钟<span class="line"></span></li>
                <li data="15" class="">15分钟<span class="line"></span></li>
                <li data="30" class="">30分钟<span class="line"></span></li>
                <li data="60" class="">60分钟<span class="line"></span></li>
                <li data="100" class="">日线<span class="line"></span></li>
            </ul>
            <div class="picTabBottomLine w100 "></div>
        </div>
      
        
<!--         
        <div id="qz-TabContent" class="introtab_content w100 of bcf" style='margin-left: -10px;'>
            <div class="w100 of bcf" style="display: block;margin-left:5px;margin-right:5px;" id="mins_chartDiv">
                    <iframe class="w100 h100 of" src="mb/jsp/mins.jsp" frameborder="0" scrolling="no"  vsspace="0" hspace="0" marginwidth="0" marginheight="0">
        			</iframe>
             </div>
             <div style="display: none;margin-left:5px;margin-right:5px;" id="K_chartDiv">
                    <iframe class="w100 h100 of" id="K_iframe" src="mb/jsp/k-painter.jsp" frameborder="0" scrolling="no"  vsspace="0" hspace="0" marginwidth="0" marginheight="0">
        			</iframe>
             </div>
        </div>
-->  
		<div class="pricetab_content w100 of bcf" style="background: #060606;margin: 0 auto;">
            <ul class="baseDateTab w100" >
                <li >&nbsp;&nbsp;当前:<span id="curChartPrice"></span></li>
                <li >开市:<span id="openChartPrice"></span></li>
                <li >最高:<span id="highChartPrice"></span></li>
                <li >最低:<span id="lowChartPrice"></span></li>
            </ul>
		</div>
		<div id="charts_ct" class="charttab_content w100 of bcf pr" style="background: #060606;margin: 0 auto;">
        	<p class="pa tr cred f12" style="display:none;z-index:20;top:10px;right:10px;padding:4px 4px;background: #ffffff;"  id="mess"><p>			
			<div id="charts1" class="chart"></div>
			<div id="charts2" class="chart"></div>
		</div>

        
    </section>
    <script>
        //tab切换
        $(function () {
        	var heightAuto = $(window).height();
        	var widthAuto = $(window).width();
        
        	$('#qz-TabContent').css('width',heightAuto);
        	
        	$('#mins_chartDiv').css('width',widthAuto);
        	$('#mins_chartDiv').css('height',widthAuto*0.7+10);
 
        	$('#K_chartDiv').css('width',widthAuto);
        	$('#K_chartDiv').css('height',widthAuto*0.7+10);       	 
        	 
        	 
        
            $('.picTab>li').mouseover(function () {
                var contentindex = $(this).index();
                $('.picTab>li').removeClass();
                $(this).addClass('pictab_current');
                
                if(contentindex==0)
                {
                    $('.charttab_content>div').eq(0).css('display', 'block');
                    $('.charttab_content>div').eq(1).css('display', 'none');                        	
                }
                else
                {
                   $('.charttab_content>div').eq(0).css('display', 'none');
                   $('.charttab_content>div').eq(1).css('display', 'block');
                   
                }
            });
            
            $("#proKind").change(function () {
                                            var optionText = $(this).find("option:selected").text();
                                            console.log(optionText);
                                               
                                            var optionValue = $(this).find("option:selected").val();	           		
                                            console.log(optionValue);	           			
						           			SetcfgObj(optionValue);
					           				chartsinit(cfgObj);
					           				
            });
            
        });
    </script>

    <section class="w100 of bcfb" >
        <div class="w100 of bcfb">
            <ul class="jiaoyiTab w100 bcf">
                <li class="jiaoyiTab_current"><img id="jiaoyi" src="mb/images/jiaoyi1.png">交易</li>
                <li class=""><img id="chicang" src="mb/images/chicang.png"/>订单<span class="line"></span></li>
                <li class=""><img id="jilu" src="mb/images/jilu.png" style="height:21px"/>记录<span class="line"></span>
                </li>
                <li class=""><img id="wodezichan" src="mb/images/wodezichan.png" style="height:20px"/>我的资产<span
                        class="line"></span></li>
            </ul>
            <div class="picTabBottomLine2 w100 "></div>
        </div>
        <div class="jiaoyiTab_content w100 of pr">
            <article class="articleJz" style="display: block;">
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">可用资金</span><span class="mgl7 f14">&yen;</span><span
                            class="f18" id="totalenablermb"></span><span class="f14"></span>
                    </div>
                    <div class="fl cred">
                        <span class="f12 c3">当前价格</span><span class="mgl7 f14">&yen;</span><span
                            class="f18" id="nowprice"></span><span class="f14"></span>
                    </div>
                </div>
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">投资金额</span><span class="mgl7 f14">&yen;</span><span
                            class="f18" id="totalBuyRmb"></span><span class="f14"></span>
                    </div>
                    <div class="fl cff9933">
                        <span class="f12 c3">手续费</span><span class="mgl7 f14">&yen;</span><span
                            class="f18" id="totalBuyRmbRate"></span><span class="f14"></span>
                    </div>
                </div>
                <div class="jydiv clearfix of">
                    <div class="fl radioDirect">
						 <span class="f12 c3 fl">委托方向</span><input type="radio" checked="checked" name="direct" value="98" id="type1" /><label for="type1" class="up">买进</label>
									   <input type="radio"  name="direct" value="115" id="type2" /><label for="type2" class="down">卖出</label>
                    </div>
                    <div class="fl cff9933">
                        <span class="f12 c3">委托数量</span><input type="number"  name="num" id="num" min="0" onblur="UpdateBuyRmb();" class="jyInput dib f12 c3 mgl7" onkeyup="value=this.value.replace(/\D+/g,'')"/>
                    </div>
                </div>
                 <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">止盈(%)</span><input type="number"  name="tppercent" id="tppercent" min="0" value="90" placeholder="不能超过100" class="jyInput dib f12 c3 mgl7" onkeyup="value=this.value.replace(/\D+/g,'')"/>
                    </div>
                    <div class="fl cff9933">
                        <span class="f12 c3">止损(%)</span><input type="number"  name="slpercent" id="slpercent" min="0" value="90" placeholder="不能超过90" class="jyInput dib f12 c3 mgl7" onkeyup="value=this.value.replace(/\D+/g,'')"/>
                    </div>
                </div>
                <div class="clearfix of">
                    <div class="vsDiv pr of">
                        <a href="javascript:void(0);" onclick="Buy();" class="db f16 cf tc jz" style="background:#3399ff">下单</a>
                        <div class="pa w100 h100" style="top:0;left: 0;z-index:-1;">
                            <div class="w100 h100">
                                <img src="mb/images/vs.png" class="db jz">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="vciLine w100 pr">
                    <div class="pa w100">
                        <span class=" f12 c9">投资有风险  参与需谨慎</span>
                    </div>
                </div>
                <div class="w100 of mgt10 mgb32">
                    <p class="w100 tc f12 c9 mgt10">市场交易由《<%=vrhome.vrcompany%>》提供服务</p>
                </div>
            </article><!--交易-->

            <article class="tabTableAarticle #f2f2f2 w100">
                <table id='cc-tableTittle' class="MyTable redTable w100 pa" border="0" style="top:0px;left:0;z-index:2;margin-top:9px;">
                    <thead class="tabhead w100 c3">
                    <tr>
                        <th style="width:26%"><p class="f11-340 w100 h100 tc">品种/投资额</p></th>
                        <th style="width:19%"><p class="f11-340 w100 h100 tc">订单/方向</p></th>
                        <th><p class="f11-340 w100 h100 tc">下单价/当前价</p></th>
                        <th style="width:30%"><p class="f11-340 w100 h100 tc">浮动盈亏/盈亏比</p></th>
                    </tr>
                    </thead>
                </table>
                 <table id='cc-tableTittleUp' class="MyTable redTable w100 pf" border="0" style="left:0;top: 0px; z-index: 2;display:none;">
                    <thead class="tabhead w100 c3">
                    <tr>
                       <th style="width:26%"><p class="f11-340 w100 h100 tc">品种/投资额</p></th>
                        <th style="width:19%"><p class="f11-340 w100 h100 tc">订单/方向</p></th>
                        <th><p class="f11-340 w100 h100 tc">下单价/当前价</p></th>
                        <th style="width:30%"><p class="f11-340 w100 h100 tc">浮动盈亏/盈亏比</p></th>
                    </tr>
                    </thead>
                </table>
                <div id='OpenOrder'>
                	
                </div>
            </article><!--持仓-->
            
  <div id="sellDialog" class="dialog pf w100 h100">
    <section class="jz of bcf">
        <div class="dialogTittle tc jz">
            提示
        </div>
        <div class="content jz lh18 f14 of">
            <div class="w100 clearfix of">
               <p class="f14 c6 fl">确定转让？</p>
            </div>
        </div>
        <div class="button w100 of clearfix">
            <button id="sure" onclick="sellVrOrder();" class="fl cf f15" style="width: 50%">确定</button>
            <button id="cancel" onclick="DialogClose($('#sellDialog'),$('.theme-popover-mask'))" class="fl cf f15" style="width: 50%;background: #CDCDCD;">取消</button>
        </div>
    </section>
</div>           
            
            
            
 		  <article class="#f2f2f2 w100" style="width: 100%;margin-bottom: 0;" >
            <table id='tableTittleUp' class="greenTable w100 pf" border="0" style="top:0px;;z-index:2;display:none" >
                 <thead class="tabhead w100 c3">
                    <tr>
                        <th style="width:26%"><p class="f11-340 w100 h100 tc">投资额/手续费</p></th>
                        <th style="width:19%"><p class="f11-340 w100 h100 tc">数量/方向</p></th>
                        <th><p class="f11-340 w100 h100 tc">下单价/转让价</p></th>
                        <th style="width:30%"><p class="f11-340 w100 h100 tc">订货盈亏/盈亏比</p></th>
                    </tr>
                    </thead>          
            </table>
            <table id='tableTittle' class="greenTable w100 pa" border="0" style="top:0px;left:0;z-index:2;margin-top:9px;" >
                 <thead class="tabhead w100 c3">
                    <tr>
                        <th style="width:26%"><p class="f11-340 w100 h100 tc">投资额/手续费</p></th>
                        <th style="width:19%"><p class="f11-340 w100 h100 tc">数量/方向</p></th>
                        <th><p class="f11-340 w100 h100 tc">下单价/转让价</p></th>
                        <th style="width:30%"><p class="f11-340 w100 h100 tc">订货盈亏/盈亏比</p></th>
                    </tr>
                    </thead>          
            </table>
               
            <div id="preOrder" class="w100" style="margin-top:45px;"></div>


            </article><!--记录-->
            
            
            
            
            <article class="articleJz">
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">本金</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="totalvrprinciplelVrRmb"></span>
                    </div>
                    <div class="fr cff9933 tl" style="min-width:160px;">
                        <span class="f12 c3">赠券</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="totalvrcashgiftVrRmb"></span>
                    </div>
                </div>
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">总资产</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="totalVrRmb"></span>
                    </div>
                </div>  
                
                             
                           
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">总资产</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="netvalueRmb"></span>
                    </div>
                    <div class="fr cff9933 tl" style="min-width:160px;">
                        <span class="f12 c3">可用资金</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="balanceRmb"></span>
                    </div>
                </div>
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                        <span class="f12 c3">占用资金</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="usedRmb"></span>
                    </div>
                </div> 
                
                
                <div class="jydiv clearfix of">
                    <div class="fl cred">
                        <span class="f12 c3">交易盈亏</span><span class="mgl7 f14">&yen;</span><span
                            class="f18"></span><span class="f14" id="totalplVrRmb"></span>
                    </div>
                    <div class="fr cred tl" style="min-width:160px;">
                        <span class="f12 c3">盈亏率</span><span class="mgl7 f14"></span><span class="f14" id="totalVrfplRmbRate"></span><span
                            class="f14"> %</span>
                    </div>
                </div>
                <div class="jydiv clearfix of">
                    <div class="fl cff9933">
                    	<span class="f12 c3">可转资金</span><span class="mgl7 f14">&yen;</span><span
                            class="f14" id="withdrawRmb"></span><span class="f14" ></span>
                    </div>
                </div>
                
                
    
                <div class="vciLine w100 pr" style="margin-top: 30px;">
                </div>
                <div class="w100 of mgt10 mgb32">
                    <p class="w100 tc f12 c9 mgt10">您为合作方[七彩云购]用户，转出将转至您的七彩云购账户</p>
                </div>
                <div class="clearfix of">
                    <div class="vsDiv pr of">
                        <a href="mb/jsp/saveMoney.jsp" class="db f16 cf tc fl" style="background:#ff9933">资金转入</a>
                        <a href="javascript:void(0)" onclick="outFundsDialog();" class="db f16 cf tc fr" style="background:#3399ff">资金转出</a>
                    </div>
                </div>

            </article><!--我的资产-->
        </div>
    </section>
    


    <script>
        
        $(function () {
           var $tableTop  = $(".jiaoyiTab_content").offset().top -250;
  			
            //            固定表头
            var flag;          
			$(window).scroll(function(){
						var h=$(this).scrollTop();//获得滚动条距top的高度
						if (flag == 1) {
						 if(h > $tableTop ){
						        $("#cc-tableTittleUp").fadeIn();
						        $("#cc-tableTittle").fadeOut();
						    }else{
						    	$("#cc-tableTittleUp").fadeOut();
						        $("#cc-tableTittle").fadeIn();
						    }
						
						}
						else if(flag == 2){
						 if(h > $tableTop){
						       
						        $("#tableTittleUp").fadeIn();
						        $("#tableTittle").fadeOut();
						    }else{
						    	$("#tableTittleUp").fadeOut();
						        $("#tableTittle").fadeIn();
						    }
						}   	   
			});
			
           //            tab切换

            $('.jiaoyiTab>li').click(function () {
                var $t = $(this).index();
                var iconImg = $(this).children('img');
                switch ($t) {
                    case 0:
                        $("#jiaoyi").attr("src", "mb/images/jiaoyi1.png");
                        $("#chicang").attr("src", "mb/images/chicang.png");
                        $("#jilu").attr("src", "mb/images/jilu.png");
                        $("#wodezichan").attr("src", "mb/images/wodezichan.png");
                        break;
                    case 1:
                        flag = 1;
                        $("#jiaoyi").attr("src", "mb/images/jiaoyi.png");
                        $("#chicang").attr("src", "mb/images/chicang1.png");
                        $("#jilu").attr("src", "mb/images/jilu.png");
                        $("#wodezichan").attr("src", "mb/images/wodezichan.png");
                        break;
                    case 2:
                         flag = 2;
                        $("#jiaoyi").attr("src", "mb/images/jiaoyi.png");
                        $("#chicang").attr("src", "mb/images/chicang.png");
                        $("#jilu").attr("src", "mb/images/jilu1.png");
                        $("#wodezichan").attr("src", "mb/images/wodezichan.png");
                        break;
                    case 3:
                        $("#jiaoyi").attr("src", "mb/images/jiaoyi.png");
                        $("#chicang").attr("src", "mb/images/chicang.png");
                        $("#jilu").attr("src", "mb/images/jilu.png");
                        $("#wodezichan").attr("src", "mb/images/wodezichan1.png");
                        break;
                }
                
                switch($t)
                        {
                        	case 0:
                        		openOrders=[];
	                        	loadMyVrInfo();
	                        	break;
                         	case 1:
	                         	loadMyVrOpen();
	                        	break;                       	
                         	case 2:
                         		openOrders=[];
                         		loadMyVrHistoryFinishOrder();
	                         	//loadMyVrPreOrder();
	                        	break;
                         	case 3:
                         		openOrders=[];
	                         	loadMyUserFundInfo();
	                        	break;
                       	                       
                        }


                $('.jiaoyiTab>li').removeClass();
                $(this).addClass('jiaoyiTab_current');
                $('.jiaoyiTab_content>article').css('display', 'none');
                $('.jiaoyiTab_content>article').eq($t).css('display', 'block');
            });
        });



    var vrGoodsList=[];//所有资产品种大类小类商品参数
    var cfgObj={}; //当前选择的资产品种大类小类商品参数
    var quotes=[]; //所有资产大类的大盘行情基础数据
    var userVrfund={};//交易所帐户资金
    var userShopfund={};//商城帐户资金
    var openOrders=[]; //持仓
    var ordersnVal=0,orderamountVal=0,goodscodeVal=0;
    
    function Dialog(dialog,mask) {
        var dialog = dialog;
        var mask = mask;
        mask.fadeIn();
        dialog.slideDown();
    }
    function DialogClose(dialog,mask) {
        var dialog = dialog;
        var mask = mask;
        mask.fadeOut();
        dialog.slideUp();
        ordersnVal=0;orderamountVal=0;goodscodeVal=0;
    }
    
    /**卖出界面当价格、数量改变,更新投资金额**/
    function UpdateSellRmb()
    {
       var sellNumVal= $.trim($("#sellNum").val());
       if(sellNumVal=='' || sellNumVal*1.0<=0  )
       {
        	return;
       }
       var sellPriceVal=$.trim($("#sellPrice").val());
       if(sellPriceVal=='' || isNaN(sellPriceVal*1.0)){
            $("#sellPrice").val(1);
            return false;    
       }
       $("#totalSellprice").html(sellNumVal*1.0*sellPriceVal);
       
    }
    
     function setTotal(countVal,price,danjia) {

        var price = price;
        var danjia = danjia;
        var danjiaPrice = danjia.val();
        
        var countVal = countVal;
        var priceTotal = danjiaPrice*countVal;
        console.log(danjiaPrice);
        price.text(priceTotal);
    }
    function addCount(count,price,danjia) {
        var count = count;
        var price = price;
        var danjia = danjia;
        count.val(parseInt(count.val())+1);
        var countVal = count.val();
        setTotal(countVal,price,danjia);
    }
    function minCount(count,price,danjia) {
        var count = count;
        var price = price;
        var danjia = danjia;

        count.val(parseInt(count.val())-1);
        if(parseInt(count.val())<1){
            count.val(1);
        }
        var countVal = count.val();
        setTotal(countVal,price,danjia);
    }
    function inputChange(count,price,danjia) {
        var count = count;
        var price = price;
        var danjia = danjia;
        var patten = /^[0-9]*[1-9][0-9]*$/;
        if(!(patten.test(count.val()))){
            count.val(1);
        }
        var countVal = count.val();
        setTotal(countVal,price,danjia);
    }
    
    
     
    function SetcfgObj(selValue)
 	{
 		
 		
 		var arrayValue=selValue.split('&');
 		var groupid=arrayValue[0];
 		var goodscode=arrayValue[1];
 		$.each(vrGoodsList, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
	    
		    if(objVal.groupid==groupid && objVal.goodscode==goodscode) {
				cfgObj=objVal;
				if(cfgObj.chargetype*1.0==50) //固定手续费
				{
					$("#opencharge").html(''+cfgObj.opencharge);
					$("#closecharge").html(''+cfgObj.closecharge);
				}
				else//49 百分比续费
				{
					$("#opencharge").html(''+cfgObj.opencharge+'%');
					$("#closecharge").html(''+cfgObj.closecharge+'%');
				}
				$("#num").attr('placeholder','最大'+cfgObj.maxperamount);
				UpdateBuyRmb();
				return ;
		    }
   		 
		});
		
 		
 	}
 	
    $().ready(function() { 
    
          var accountVal="<%=user.mobile%>";
		  var pwdVal="<%=pwdMd5%>";
    	//交易所登陆
		$.ajax({
            url: "/cgi-bin/zl_cgi?c=5",
            data: {account:accountVal,pwd:pwdVal},
            //data: ''+JSON.stringify({c:"5",f:"login",account:"13798485970",pwd:"123456"}),
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
            	console.log(data);
              if(data['retcode']==0)
              {
                loadVrGoods();
                loadMyVrInfo();
              }
			  else
			  	dealErrorCode(data['retcode']);
             },
            error: function (data) {
                showToast('网络忙，请重试');
            },
            complete: function () {
            }
        }); 
        
  	}); 
  	
    /**取资产产品**/
 	function loadVrGoods()
 	{
	 	$.ajax({
            url: "/cgi-bin/zl_cgi?c=0",
            data: {},
            //data: ''+JSON.stringify({c:"5",f:"login",account:"13798485970",pwd:"123456"}),
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
	            beforeSend: function () {
	            },
	            success: function (data) {
	            console.log(data);
	              if(data['retcode']==0)
	              {
	              		//$('#totalenablermb').html(data.obj.vrnowrmb);
	              	//数据
	           		$("#proKind").html('');
					var contentHtml="";
					if(data.goods==null)  return;
					vrGoodsList=data.goods;
					vrGoodsList.sort(function(a, b) {
		                var ai = a.showorder*1.0;
		                var bi = b.showorder*1.0;
		                if (ai > bi) {
		                    return 1;
		                } else if (ai < bi) {
		                    return -1;
		                } else {
		                    return 0;
		                }

		            });
					var splitStr="&";
	           		$.each(data.goods, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
	           		    //value=groupid & goodscode
		           		if(index==0) {
		           			contentHtml=contentHtml+'<option style="height:40px;" value ="'+objVal.groupid+splitStr+objVal.goodscode+'" selected="selected">'+objVal.groupname+'('+objVal.goodsname+')</option>';
		           			
		           			SetcfgObj(objVal.groupid+splitStr+objVal.goodscode);
	           				chartsinit(cfgObj);
		           		}
		           		else
		           		{
		           			contentHtml=contentHtml+'<option style="height:40px;" value ="'+objVal.groupid+splitStr+objVal.goodscode+'" >'+objVal.groupname+'('+objVal.goodsname+')</option>';
		           		}
	           		 
				    });
	           		$("#proKind").html(contentHtml);
	              }
				  else{
					  dealErrorCode(data['retcode']);
					  $("#proKind").html('');
				  }
				  	
	             },
	            error: function (data) {
	                showToast('网络忙，请重试');
	            },
	            complete: function () {
	            }
	        }); 
  	
 	}  	
  	       
        
      /**购买界面当价格、数量改变,更新投资金额**/
    function UpdateBuyRmb()
    {
       var numVal= $.trim($("#num").val());
       if(numVal=='' || numVal*1.0<=0  )
       {
        	$("#totalBuyRmb").html("");
       		$("#totalBuyRmbRate").html("");
        	return;
       }
        if(cfgObj.chargetype*1.0==50) //固定手续费
		{
			$("#totalBuyRmbRate").html(numVal*1.0*cfgObj.opencharge);
		}
		else//49 百分比续费
		{
			$("#totalBuyRmbRate").html(numVal*1.0*cfgObj.goodsprice*cfgObj.opencharge/100);
		}
		
       $("#totalBuyRmb").html(numVal*1.0*cfgObj.goodsprice);
       
       
    }       
        
        
     /**交易界面 取我的理财资产**/
    function loadMyVrInfo0()
    {
    
       $.ajax({
            url: "PlugServlet",
            data: ''+JSON.stringify({m:272}),
            type: 'post',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
              if(data['state']==1)
              {
              		$('#totalenablermb').html(data.obj.vrnowrmb);
              }
			  else{
				  showToast(data.info);
				  $('#totalenablermb').html("0");
			  }
			  	
             },
            error: function (data) {
                showToast('网络忙，请重试');
            },
            complete: function () {
            }
        }); 
    }      
        
    
    /**建仓**/
    function Buy()
    {
       var directValue  = $('input[name="direct"]:checked').val();
       var vrgoodsidStr =cfgObj.goodscode;
       var numVal= parseInt($.trim($("#num").val()));
       //止盈
       var tppercentVal= parseInt($.trim($("#tppercent").val()));
       //止损
       var slpercentVal= parseInt($.trim($("#slpercent").val()));
       
       if(isNaN(numVal) )
       {
       		showToast("数量不能为空");
       		return;
       }
       if(isNaN(tppercentVal))
       {
       		showToast("止盈不能为空");
       		return;
       }
       if(tppercentVal*1.0==0)
       {
       		showToast("止盈 不能为0。");
       		return;
       }
       if(isNaN(slpercentVal))
       {
       		showToast("止损不能为空");
       		return;
       }
       if(slpercentVal*1.0>90)
       {
       		showToast("止损 不超过90。");
       		return;
       }
       if(tppercentVal*1.0>100)
       {
       		showToast("止盈  不超过100。");
       		return;
       }
       if(slpercentVal*1.0==0)
       {
       		showToast("止损 不能为0。");
       		return;
       }
       if(numVal<=0)
       {
        	showToast("数量不正确。");
        	return;
       }
       var obj={goodscode:vrgoodsidStr,direct:directValue,orderamount:numVal,tppercent:tppercentVal,slpercent:slpercentVal,ordermode:'49',coupons:''};
		console.log(obj);
       $.ajax({
            url: "/cgi-bin/zl_cgi?c=23",
            data: {goodscode:vrgoodsidStr,direct:directValue,orderamount:numVal,tppercent:tppercentVal,slpercent:slpercentVal,ordermode:'49',coupons:''},
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
              if(data['retcode']==0)
              {
                layer.alert("下单成功"); 
                $("#num").val('');
       			$("#tppercent").val('');
       			$("#slpercent").val('');
			    $("#totalBuyRmb").html("");
			    $("#totalBuyRmbRate").html("");
			    
			    setTimeout(function(){
							loadMyVrInfo();
							},1000);
              }
			  else
			  	dealErrorCode(data['retcode']);
             },
            error: function (data) {
                showToast('网络忙，请重试');
            },
            complete: function () {
            }
        }); 
    }  
    
    /**取我的理财持仓**/
    function loadMyVrOpen()
    {
       $.ajax({
       		url: "/cgi-bin/zl_cgi?c=1",
            data: {},
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
            	console.log(data);
              if(data['retcode']==0)
              {
                    //数据
	           		$("#OpenOrder").html('');
					var contentHtml="";
					openOrders=[];
					if(data.orders==null)  return;
					//数据补充处理
					var vrGoodsListTmp=vrGoodsList;
					$.each(data.orders, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
	           		        for(var i=0;i<vrGoodsListTmp.length;i++)
	           		        {
	           		        	if(vrGoodsListTmp[i].goodscode==objVal.goodscode)
	           		        	{  
	           		        		objVal.groupid=vrGoodsListTmp[i].groupid; //增加商品大类属性
	           		        		objVal.agreeunit=vrGoodsListTmp[i].agreeunit; //增加商品合约单位属性 
	           		        		objVal.buypt=vrGoodsListTmp[i].buypt; //增加商品报价买点差属性
	           		        		objVal.sellpt=vrGoodsListTmp[i].sellpt; //增加商品报价卖点差属性  
	           		        		objVal.bail=objVal.bail/100;
  									objVal.fixedNumber=Math.pow(10,vrGoodsListTmp[i].mindecimal); //增加商品小数位值属性
	           		        		openOrders.push(objVal);
	           		        		break;
	           		        	}
	           		        }
					});
					openOrders.sort(function(a, b) 
					{
						var ai = a.opensn*1.0;
						var bi = b.opensn*1.0;
							                
						if (ai > bi) {
							 return -1;
						} else if (ai < bi) {
							 return 1;
						} else {
							return 0;
						}
					});
					//生成html
					createHtmlForOpenOrder();
              }
			  else
			  	dealErrorCode(data['retcode']);
             },
            error: function (data) {
                showToast('网络忙，请重试');
            },
            complete: function () {
            }
        }); 
    }   

    
  /**平仓**/
    function sellVrOrderDialog(ordersnV,orderamountV,goodscodeV)
    {
        Dialog($('#sellDialog'),$('.theme-popover-mask'));
        
        ordersnVal=ordersnV;orderamountVal=orderamountV;goodscodeVal=goodscodeV;
    }
    
    /**持仓卖出即平仓**/
    function sellVrOrder()
    {
    
       $.ajax({
            url: "/cgi-bin/zl_cgi?c=39",
            data: {ordersn:ordersnVal,orderamount:orderamountVal,goodscode:goodscodeVal},
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
              if(data['retcode']==0)
              {
              		 showToast("转让成功");
              		 setTimeout(function(){
              		 	openOrders=[];
						loadMyVrHistoryFinishOrder();
              		 	loadMyVrOpen();
              		 	loadMyVrInfo();
							
					},1000);

              }
			  else{
				  dealErrorCode(data['retcode']);
			  }
			  	
             },
            error: function (data) {
                showToast('网络忙，请重试');
            },
            complete: function () {
                DialogClose($('#sellDialog'),$('.theme-popover-mask'));
            }
        }); 
    }        
  
    
        
        
        
        
 /**取我的理财资产(交易所帐户)**/
    function loadMyVrInfo()
    {
    
       $.ajax({
            url: "/cgi-bin/zl_cgi?c=8",
            data: {},
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
              if(data['retcode']==0)
              {
              	userVrfund=data.userfund;
              	$('#totalenablermb').html(userVrfund.balance/100);
              }
			  else
			  	dealErrorCode(data['retcode']);
             },
            error: function (data) {
                showToast('网络忙，请重试');
            },
            complete: function () {
            }
        }); 
    }       
        
  
    //生成html 
    function createHtmlForOpenOrder()
    {
      	if(openOrders.length==0) return;
     	$("#OpenOrder").html('');
    	var contentHtml='';
    	$.each(openOrders, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
    		                var close=0;
	           		        for(var i=0;i<quotes.length;i++)
	           		        {
	           		        	if(quotes[i].groupid==objVal.groupid)
	           		        	{   
	           		        		close=quotes[i].close/objVal.fixedNumber;
	           		        		break;
	           		        	}
	           		        }
	           		        
	           		         var openprice=objVal.openprice/objVal.fixedNumber;
	           		         var shareRmb=0;//浮动盈亏
	                         if(objVal.direction*1.0==98) //是买涨
	                         {
	                         	shareRmb=objVal.agreeunit*objVal.openamount*(close*1.0+objVal.sellpt/objVal.fixedNumber*1.0-openprice*1.0);
	                         }
	                         else //是买跌
	                         {
	                         	shareRmb=objVal.agreeunit*objVal.openamount*(openprice*1.0+objVal.buypt/objVal.fixedNumber*1.0-close*1.0);
	                         }
							 
							 var shareRmbRate=0; //浮动盈亏率
							 shareRmbRate=100*shareRmb/(objVal.bail);//百分比
	           		         shareRmbRate=getMrZear(shareRmbRate);
	           		         shareRmb=getMrZear(shareRmb);
	           		         
	           		         var chargermb=0;//手续费
                             chargermb=Math.abs(objVal.opencharge*1.0+objVal.closecharge*1.0)/100;
                             
					   if(shareRmbRate>(0-objVal.slpercent*1.0) && shareRmbRate<objVal.tppercent*1.0)
                       {
							contentHtml=contentHtml+'<table class="greenTable" border="0">'+
					                    '<tbody class="f13 c9">'+
					                    '<tr>'+
					                        '<td>'+objVal.goodsname+'</td>'+
					                        '<td>'+objVal.openamount+'</td>'+
					                        '<td>'+objVal.openprice/objVal.fixedNumber+'</td>';
					                        
						    if(shareRmb>=0)
							{           
									contentHtml=contentHtml+'<td class="cred">'+shareRmb+'</td>';
									
							}else
							{
									contentHtml=contentHtml+'<td class="cgreen">'+shareRmb+'</td>';
							}                   
						                        
					                        
					                        
					            contentHtml=contentHtml+'</tr>'+
					                    '<tr>'+
					                        '<td>'+objVal.bail+'('+chargermb+')</td>';

					                        
						    if(objVal.direction*1.0==98)
		                        	contentHtml=contentHtml+'<td  class="cred">买进</td>';
		                    else
		                        	contentHtml=contentHtml+'<td class="cgreen">卖出</td>';
		                        	
						            
					            
					            
						    if(close*1.0>=openprice*1.0)
		                    {
		                         	contentHtml=contentHtml+'<td class="cred">'+getMrZear(close)+'</td>';
		                    }
		                    else
		                    {
		                         	contentHtml=contentHtml+'<td class="cgreen">'+getMrZear(close)+'</td>';
		                    }        
						    if(shareRmb>=0)
							{           
									contentHtml=contentHtml+'<td class="cred">'+shareRmbRate+'%</td>';
									
							}else
							{
									contentHtml=contentHtml+'<td class="cgreen">'+shareRmbRate+'%</td>';
							}
						                        
					        contentHtml=contentHtml+'</tr>'+
					                    '</tbody>'+
					                    '<tfoot>'+
					                    '<tr>'+
					                        '<td colspan="3"><p class="f12 c9 fl">&nbsp;&nbsp;&nbsp;&nbsp;下单时间&nbsp;&nbsp;'+objVal.opentime+'</p></td>'+
					                        '<td class="f13" colspan="1" style="color:#0066ff;"><a href="javascript:void(0);" onclick="sellVrOrderDialog(\''+objVal.opensn+'\',\''+objVal.openamount+'\',\''+objVal.goodscode+'\');">转让</a></td>'+
					                    '</tr>'+
					                    '</tfoot>'+
					                '</table>'+
					                '<section class="w100 tableLine"></section>';
						}
		
		});
		$("#OpenOrder").html(contentHtml);
				    
				    
	           		
    }
    
    /**取我的 当天或历史  盈亏记录**/
    function loadMyVrHistoryFinishOrder(day)
    {
    	
		var startdayVal='<%=startdayVal%>',enddayVal='<%=enddayVal%>', dataObj={}, toUrl='';
		toUrl="/cgi-bin/zl_cgi?c=30";
		dataObj={sorttype:'50',count:'20',id:'0'};
       $.ajax({
            url: toUrl,
            
            data: dataObj,
            type: 'get',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            
            beforeSend: function () {
            },
            success: function (data) {
            	console.log(data);
              if(data['retcode']==0)
              {
              		$("#preOrder").html('');
              		var todatyData=[];
                    var last30Data=[];
                    if(data.data!=null && data.data!='') todatyData=data.data;
              
              		toUrl="/cgi-bin/zl_cgi?c=16";
					dataObj={startday:startdayVal,endday:enddayVal,sorttype:'50',count:'100',id:'0'};
					$.ajax({
					            url: toUrl,
					            data: dataObj,
					            type: 'get',
					            dataType: 'json',
					            contentType:"application/json;charset=utf-8",
					            
					            beforeSend: function () {
					            },
					            success: function (data2) {
					              console.log(data2);
					              if(data2['retcode']==0)
					              {
					              	if(data2.data!=null && data2.data!='')
					              	   last30Data=data2.data;
					              	   
					              	//数据
										console.log(todatyData);
										console.log(last30Data);
					                    var temp=$.merge(todatyData,last30Data);
					                    console.log(temp);
					
										var contentHtml="";
										var finishOrder=[];
										
										//数据补充处理
										$.each(temp, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
						           		       if(objVal.tradetype*1.0!=49)//tradetype 49：开仓　50:平仓　51:交割
						           		       {
						           		        	for(var i=0;i<vrGoodsList.length;i++)
						           		        	{
							           		        	if(vrGoodsList[i].goodscode==objVal.goodscode)
							           		        	{  
							           		        		objVal.groupid=vrGoodsList[i].groupid; //增加商品大类属性
							           		        		objVal.agreeunit=vrGoodsList[i].agreeunit; //增加商品合约单位属性 
							           		        		objVal.buypt=vrGoodsList[i].buypt; //增加商品报价买点差属性
							           		        		objVal.sellpt=vrGoodsList[i].sellpt; //增加商品报价卖点差属性
							           		        		objVal.goodsname=vrGoodsList[i].goodsname;
							           		        		objVal.bail=objVal.bail/100;
						  									objVal.fixedNumber=Math.pow(10,vrGoodsList[i].mindecimal); //增加商品小数位值属性
							           		        		finishOrder.push(objVal);
							           		        		break;
							           		        	}
						           		        	}
						           		       }
										});
										
										finishOrder.sort(function(a, b) {
											//2017-03-28 22:56:05  20170328225605
											var aStr=a.closetime;
											var bStr=b.closetime;
											aStr=aStr.replace('-','');
											aStr=aStr.replace('-','');
											aStr=aStr.replace(':','');
											aStr=aStr.replace(':','');
											aStr=aStr.replace(' ','');
										
											bStr=bStr.replace('-','');
											bStr=bStr.replace('-','');
											bStr=bStr.replace(':','');
											bStr=bStr.replace(':','');
											bStr=bStr.replace(' ','');
										
							                var ai = aStr*1.0;
							                var bi = bStr*1.0;
							                
							                if (ai > bi) {
							                    return -1;
							                } else if (ai < bi) {
							                    return 1;
							                } else {
							                    return 0;
							                }
					
							            });
									    
						           		$.each(finishOrder, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
						           		
						           		contentHtml=contentHtml+'<table class="greenTable" border="0">'+ 
									                         '<thead class="insetThead f13 c9">'+
															 '<tr>'+
															 	'<td colspan="2" class="tl">&nbsp;&nbsp;&bull;&nbsp;单号：'+objVal.opensn+'</td>'+
															 	'<td colspan="2" class="tr">'+objVal.goodsname+'&nbsp;&nbsp;</td>'+
															 '</tr>'+
															'<thead>'+
										                    '<tbody class="f13 c9">'+
										                    '<tr>'+
										                        '<td>'+objVal.bail+'</td>'+
										                        '<td>'+objVal.openamount+'</td>'+
										                        '<td>'+objVal.openprice/objVal.fixedNumber+'</td>';

												  var shareRmb=0;//结算盈亏
												  if(objVal.closetime=='')         
												  {
												  		shareRmb=objVal.clearpl/objVal.fixedNumber;
												  }
												  else
												  {
												  		shareRmb=objVal.pl/objVal.fixedNumber;
												  }     
		 		                                 if(objVal.direction*1.0==98) //是买涨
						                         {
						                         	shareRmb=objVal.agreeunit*objVal.openamount*(objVal.closeprice*1.0+objVal.sellpt*1.0-objVal.openprice*1.0)/objVal.fixedNumber;
						                         }
						                         else //是买跌
						                         {
						                         	shareRmb=objVal.agreeunit*objVal.openamount*(objVal.openprice*1.0+objVal.buypt*1.0-objVal.closeprice*1.0)/objVal.fixedNumber;
						                         }
												 var shareRmbRate=0; //盈亏率
												 shareRmbRate=100*shareRmb/(objVal.bail);//百分比 
										                        
										         var chargermb=0;//手续费
					                             chargermb=Math.abs(objVal.opencharge*1.0+objVal.closecharge*1.0)/100;                
										           
										                        
										    if(shareRmb>=0)
											{           
													contentHtml=contentHtml+'<td class="cred">'+getMrZear(shareRmb)+'</td>';
													
											}else
											{
													contentHtml=contentHtml+'<td class="cgreen">'+getMrZear(shareRmb)+'</td>';
											}                   
											                        
										                        
										                        
										            contentHtml=contentHtml+'</tr>'+
										                    '<tr>'+
										                        '<td>'+chargermb+'</td>';
					
										                        
										    if(objVal.direction*1.0==98)
						                        	contentHtml=contentHtml+'<td  class="cred">买进</td>';
						                    else
						                        	contentHtml=contentHtml+'<td class="cgreen">卖出</td>';
						                        	
										            
										    if(objVal.closetime=='')         
											{        
														contentHtml=contentHtml+'<td >--</td>';
										    }  
										    else
										    {   
											    if(objVal.closeprice*1.0>=objVal.openprice*1.0)
							                    {
							                         	contentHtml=contentHtml+'<td class="cred">'+objVal.closeprice/objVal.fixedNumber+'</td>';
							                    }
							                    else
							                    {
							                         	contentHtml=contentHtml+'<td class="cgreen">'+objVal.closeprice/objVal.fixedNumber+'</td>';
							                    }  
						                    }      
										    if(shareRmb>=0)
											{           
													contentHtml=contentHtml+'<td class="cred">'+getMrZear(shareRmbRate)+'%</td>';
													
											}else
											{
													contentHtml=contentHtml+'<td class="cgreen">'+getMrZear(shareRmbRate)+'%</td>';
											}
										             
										     if(objVal.closetime=='')         
										     {
										     		contentHtml=contentHtml+'</tr>'+
										                    '</tbody>'+
										                    '<tfoot>'+
										                    '<tr>'+
										                        '<td colspan="3"><p class="f12 c9 fl">&nbsp;&nbsp;转让时间：&nbsp;&nbsp;&nbsp;&nbsp;订单持有&nbsp;&nbsp;&nbsp;&nbsp;</p></td>';
										     }
										     else
										     {
										     		 contentHtml=contentHtml+'</tr>'+
										                    '</tbody>'+
										                    '<tfoot>'+
										                    '<tr>'+
										                        '<td colspan="3"><p class="f12 c9 fl">&nbsp;&nbsp;转让时间：'+objVal.closetime+'</p></td>';
										     }
										               
								
										     
										     if(objVal.closeremark==undefined  && objVal.closemark==undefined)
										     {
										     		contentHtml=contentHtml+'<td class="f12" colspan="1" ></td>';
										     }     
										     else
										     {
										     		if(objVal.closeremark==undefined)//历史
										     			contentHtml=contentHtml+'<td class="f12" colspan="1" >'+objVal.closemark+'</td>';
										     		else//当天
										     			contentHtml=contentHtml+'<td class="f12" colspan="1" >'+objVal.closeremark+'</td>'; 
										     }    
        
										            contentHtml=contentHtml+
										                    '</tr>'+
										                    '</tfoot>'+
										                '</table>'+
										                '<section class="w100 tableLine"></section>';
					       
									    });
						           		$("#preOrder").html(contentHtml);   
					              }
								  else    
								  	dealErrorCode(data['retcode']);
					             },
					            error: function (data) {
					                layer.alert('网络忙，请重试');
					            },
					            complete: function () {
					            }
					 });
              
              
              
                    
              }
			  else    
			  	dealErrorCode(data['retcode']);
             },
            error: function (data) {
                layer.alert('网络忙，请重试');
            },
            complete: function () {
            }
        }); 
    }        
    
    
    
 /**取我的理财资产(商城帐户与交易所帐户)**/
    function loadMyUserFundInfo()
    {
    	userShopfund={};
    	userVrfund={};
    	
    	$.ajax({
            url: "PlugServlet",
            data: ''+JSON.stringify({m:272}),
            type: 'post',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
              if(data['state']==1)
              {
              		userShopfund=data.obj;
              		$.ajax({
			            url: "/cgi-bin/zl_cgi?c=8",
			            data: {},
			            type: 'get',
			            dataType: 'json',
			            contentType:"application/json;charset=utf-8",
			            beforeSend: function () {
			            },
			            success: function (data) {
			              if(data['retcode']==0)
			              {
			              	  userVrfund=data.userfund;
			              }
						  else
						  	dealErrorCode(data['retcode']);
			             },
			            error: function (data) {
			                layer.alert('网络忙，请重试');
			            },
			            complete: function () 
			            {
				            console.log(userShopfund);
					    	console.log(userVrfund);
					    	    
					    	if(!isEmptyObject(userShopfund) && !isEmptyObject(userVrfund))
					    	{
					 
					    		//更新UI数据
					    		$('#totalvrprinciplelVrRmb').html(getMrZear(userShopfund.vrprinciplelrmb));
					    		$('#totalvrcashgiftVrRmb').html(getMrZear(userShopfund.vrcashgiftrmb1*1.0+userShopfund.vrcashgiftrmb2*1.0));
					    		var total=userShopfund.vrprinciplelrmb*1.0+userShopfund.vrcashgiftrmb1*1.0+userShopfund.vrcashgiftrmb2*1.0;
					    		$('#totalVrRmb').html(getMrZear(total));
					    		
					    		$('#netvalueRmb').html(getMrZear(userVrfund.netvalue/100));
					    		$('#balanceRmb').html(getMrZear(userVrfund.balance/100));
					    		$('#usedRmb').html(getMrZear(userVrfund.used/100));
					    		//$('#chargeRmb').html(getMrZear((userVrfund.inoutcharge*1.0+userVrfund.charge*1.0)/100));
					    		var pl=userVrfund.netvalue/100*1.0-total; //盈亏
					    		
					    		//$('#totalplVrRmb').html(getMrZear(userVrfund.pl*1.0/100));
					    		$('#totalplVrRmb').html(getMrZear(pl));
					    		if(pl==0 || total==0)
					    		{
					    			$('#totalVrfplRmbRate').html('0');
					    		}
					    		else
					    		{
					    			$('#totalVrfplRmbRate').html(getMrZear(100*pl/total));
					    		}
					    		
					    		//$('#withdrawRmb').html(userVrfund.balance/100-userShopfund.vrcashgiftrmb1*1.0+userShopfund.vrcashgiftrmb2*1.0);
								$('#withdrawRmb').html(getMrZear((userVrfund.netvalue*1.0)/100));
					    	}
			            
			            }
			        }); 
              }
			  else{
				  layer.alert(data.info);
			  }
			  	
             },
            error: function (data) {
                layer.alert('网络忙，请重试');
            },
            complete: function () 
            {
            }
        }); 
    
    }    
    
   /**出金 对话框**/
    function outFundsDialog()
    {
        showTipDialog('提示','您确定出金？出金的前提，不能有订单持有!',outFunds,3);
    } 

   /**出金**/
	function outFunds()
	{
		//先取得当前用户在市场中的市场总资产
		$.ajax({
			  url: "/cgi-bin/zl_cgi?c=8",
			  data: {},
			  type: 'get',
			  dataType: 'json',
			  contentType:"application/json;charset=utf-8",
			  beforeSend: function () {
			  },
			  success: function (data) {
			    if(data['retcode']==0)
			    {
			        var netvalueRmb=getMrZear((data.userfund.netvalue*1.0)/100);
			        doOutFunds(netvalueRmb*1.0);
 			    }
				else
					dealErrorCode(data['retcode']);
			    },
			    error: function (data) {
			        layer.alert('网络忙，请重试');
			    },
			    complete: function () 
			    {
			    
			    }
		});
	}  
 
 
 function doOutFunds(netRmb)
 {
		
		$.ajax({
		            url: "PlugServlet",
		            data: ''+JSON.stringify({m:244,netvalueRmb:netRmb}),
		            type: 'post',
		            dataType: 'json',
		            contentType:"application/json;charset=utf-8",
		            beforeSend: function () {
		            },
		            success: function (data) {
		              console.log(data);
		              if(data['state']==1)
		              {
		                showToast(data.info);
	                    setTimeout(function(){
              		 		openOrders=[];
	                    	loadMyUserFundInfo();
						},1000);
		              }
					  else
					  	showToast(data.info);
		             },
		            error: function (data) {
		                showToast('网络忙，请重试');
		            },
		            complete: function () {
		            	cancelDialog();
		            }
		        });  
 
 }   
    
    
    </script>


</div>

</body>
</html>
